package com.sanyang.pda.ui.crossdocking;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.sanyang.pda.adapter.CrossDockingAdapter;
import com.sanyang.pda.bean.CrossDockingBean;
import com.sanyang.pda.bean.ManualPickingBean;
import com.sanyang.pda.contract.CrossDockingContract;
import com.sanyang.pda.presenter.CrossDockingPresenter;
import com.sanyang.pda.utils.StringConfig;
import com.wangshen.base.app.AppActivityKey;
import com.wangshen.base.ui.mvp.base.adapter.BaseAdapter;
import com.wangshen.base.ui.mvp.base.refresh.BaseRecyclerRefreshActivity;
import com.wangshen.projectbase.R;

import java.util.ArrayList;
import java.util.List;

@Route(path = AppActivityKey.CROSSDOCKINGACTYIVITY)
public class CrossDockingActyivity extends BaseRecyclerRefreshActivity<CrossDockingPresenter> implements CrossDockingContract.View {

    @Override
    public BaseAdapter createRecyclerAdapter() {
        return new CrossDockingAdapter(R.layout.item_cross_docking,new ArrayList<>());
    }

    @Override
    public CrossDockingPresenter getPresenter() {
        return new CrossDockingPresenter();
    }

    @Override
    public void initView() {
        View view= LayoutInflater.from(mContext).inflate(R.layout.layout_title,llRoot,false);
        llRoot.addView(view,0);
        TextView textView=view.findViewById(R.id.tv_title);
        textView.setText(getString(R.string.cross_docking));
        ImageView back=view.findViewById(R.id.iv_back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finishActivity();
            }
        });
    }

    @Override
    public void initLinsenterner() {
        getRecyclerAdapter().setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
                List<CrossDockingBean> list = (List<CrossDockingBean>) adapter.getData();
                Bundle bundle = new Bundle();
                bundle.putString(StringConfig.DELIVERYNO, list.get(position).getDeliveryNo());
                startIntent(AppActivityKey.MANUALOUTBOUNDDETAILACTIVITY, bundle);
            }
        });
    }

    @Override
    public void getData() {
        getRefreshLayout().autoRefresh();
    }
}
